package com.benyi.byiee.util;

import java.util.HashMap; 
import java.util.UUID;

import com.benyi.byiee.model.api.User;

public class OnlineUserList {
	private static HashMap<String,User> list = new HashMap<String,User>();
	
	public static int getUserNum() {
		return list.size();
	}
	
	public static HashMap<String,User> getUserList(){
		return list;
	}
	
	public static String createToken() {
		String id = UUID.randomUUID().toString();
		return id;
	}
	
	public static void putUser(String token, User u) {
		if(token == null || u == null) {
			return;
		}
		list.put(token, u);
	}
	
	public static User getUser(String token) {
		if(token==null) return null;
		User u = list.get(token);
		return u;
	} 
	 
	
	public static void removeUser(String token) {
		if(token == null) {
			return;
		}
		list.remove(token);
	} 
	
}
